<?php
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
	include '../../connection/connection.php';	
	include "../../value/value_kr.php";
	
	$list=$_SESSION['sort'];
	$str=$_GET['string'];
	$_SESSION['sortn']=$str;
	$flagDesc=$_GET['flagDesc'];
	$winH = $_REQUEST['winH'];
	
	if($flagDesc==1){

		if($list[$str]=="DESC")
			$list[$str]="ASC";
		else
			$list[$str]="DESC";
	}
	$selectcount = mysql_query("SELECT COUNT(*) as total FROM carcrime c,caruser u WHERE c.iUser =u.iUser and c.cameraID=0 ",$connection);
	$count = mysql_fetch_assoc($selectcount);
	$sql = "select c.id,c.carnum,c.regNote,c.regDatetime,u.szUser from carcrime c,caruser u WHERE c.iUser =u.iUser and c.cameraID=0 ";
	$selectallcarcrime = mysql_query($sql." ORDER BY ".$str." ".$list[$str], $connection);
	$_SESSION['sort']=$list;
	
	?>
 <div style="overflow:scroll;overflow-x: hidden; width:100%; height:<?php echo ($winH-270)."px"?>; background-color: #ffffff">
	        <table cellpadding="0" cellspacing="0" border="0" width="100%" class="tbchung" id="tablebody2">
	            <tbody>
	            <?php 
	            		$i = 0;
	           		while ($rowcar = mysql_fetch_array($selectallcarcrime)) {
	             		$i++;?>
		            <tr onclick="onclickrecordcheck('checkboxcarcrime<?=$i?>');">
		                <td style="width: 5%;text-align: center;"><input onclick="onclickrecordcheck('checkboxcarcrime<?=$i?>');" type="checkbox" name="checkboxcarcrime[]" id="checkboxcarcrime<?=$i?>"  value="<?=$rowcar[id]?>" class="checkCamera" /></td>
		               	<td style="width: 5%;text-align: center;"><?=$i?></td>
		                <td style="width: 25%;"><?php if ($rowcar[carnum]==''){echo "&nbsp;";}else{?> <?=$rowcar[carnum]?><?php }?></td>
		                <td style="width: 25%;"><?php if ($rowcar[regNote]==''){echo "&nbsp;";}else{?> <?=$rowcar[regNote]?><?php }?></td>
		                <td style="width: 20%;"><?=$rowcar[regDatetime]?></td>
		                <td style="width: 20%;" class="last"><?=$rowcar[szUser]?></td>
		            </tr>
	             <?php
						}
						if ($i>0 and $i<($winH/28)) {
							 	foreach(range(0,($winH/28)-$i) as $real){
							 		?>
							 		<tr>
								 		<td width="5%">&nbsp;</td>
								 		<td width="5%">&nbsp;</td>
								 		<td width="25%">&nbsp;</td>
									 	<td width="25%">&nbsp;</td>
									 	<td width="20%">&nbsp;</td>
									 	<td class="last" style="width: 20%;border-right: none !important;">&nbsp;</td>
								 	</tr>
							 	<?php }
							}?>
							
	            </tbody>              
	        </table>
	        </div>
	        <div>
	        	<table>
	        		<tr>
						<td class="rf-dt-ftr-carcrime-user" style="text-align: left;padding-top: 15px; " colspan="7">
						<!-- <input type="button" class="inbtn" value="Load All" onclick="loadAdll_carcrimeUser();"/><label style="color: white;padding-left: 10px;">   |  </label> -->
						<label style="color: white;padding-left: 15px;">  <?php echo $l_totalrecord?> <?=$count[total]?></label>
						</td>
						
					</tr>	
	        	</table>
	        </div>
      <?php mysql_close($connection);?>   